Skip to content

Test against symfony versions #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Nov 30, 2017
Merged

Test against symfony versions #90

merged 27 commits into from
Nov 30, 2017

Conversation

Nyholm
Copy link
Member

@Nyholm Nyholm commented Nov 18, 2017

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Related tickets
Documentation if this is a new feature, link to pull request in https://github.com/php-http/documentation that adds relevant documentation
License MIT

What's in this PR?

I want to test with different versions of the options-resolver.

Why?

Im experimenting to see if the symfony/lts is something that should be used in travis.yml for more bundles.

#SymfonyConHackday2017

@Nyholm
Copy link
Member Author

Nyholm commented Nov 18, 2017

We would like to keep tests for beta and the 2 latest Symfony LTS.

Ping @weaverryan.

This does not quite work.. When Symfony 4.0 is released we do no longer test SF3.4... I will do another attempt later.

@Nyholm
Copy link
Member Author

Nyholm commented Nov 18, 2017

I think I found the "perfect" travis.yml.

The current state of the PR has "symfony/options-resolver": "^2.6 || ^3.0". Travis will test against the following:

  • SF 2.6 (lowest)
  • SF 3.3 (Current latest stable)
  • SF 2.8 (LTS v2)
  • SF 3.3 (LTS v3) (Same as above)
  • SF 3.4-beta (Beta) (Allowed to fail)

When Symfony 4 is released and I do not change my library requirements, Travis will test the following:

  • SF 2.6 (lowest)
  • SF 3.4 (Current latest stable) <--- Change
  • SF 2.8 (LTS v2)
  • SF 3.4 (LTS v3) (Same as above) <--- Change
  • SF 3.4-beta (Beta) (Allowed to fail) <--- Now meaningless.

If I update my requirements to "symfony/options-resolver": "^2.6 || ^3.0 || ^4.0" after Symfony 4 is released:

  • SF 2.6 (lowest)
  • SF 4.0 (Current latest stable) <--- Change
  • SF 2.8 (LTS v2)
  • SF 3.4 (LTS v3)
  • SF 4.0-beta (Beta) (Allowed to fail) <--- Will have a purpose before 4.0 is released

FYI @stof, @nicolas-grekas

.travis.yml Outdated
- php: 5.4
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci"

env: DEPENDENCIES="minimun" COVERAGE=true TEST_COMMAND="composer test-ci"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimum

.travis.yml Outdated

# Test LTS versions
- php: 7.1
env: DEPENDENCIES="symfony/lts:v2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clever use of the package, great discovery!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if some bundle authors actively only want to support 2 Symfony versions at one time? What's what we're talking about in FOSUserBundle FriendsOfSymfony/FOSUserBundle#2639 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can still install a mixed set of 2.7 and 2.8 components. What about using symfony/symfony:v2.8.* which will force any symfony component to be in it's v2.8 version?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I realize I was unclear! What I really mean was: in FOSUserBundle, they only want to support Symfony 3 and Symfony 4 (and then perhaps just do bug-fixes fro 2.7/2.8 branches).

In that situation, I guess they would just remove this one line and change the minimum dependencies matrix to 5.5 (from 5.4)?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the Symfony 2 LTS job and bump your min requirement

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weaverryan they in FOSUserBundle refers to only one maintainer of the bundle actually. I had not even seen this discussion yet (it was hidden in the middle of the thousand notifications I received during the hackday)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re requiring symfony/symfony: that hides problems if we miss depending on some symfony components. if we do that, we should require each component we use in the configured version instead. (which duplicates composer.json, so still not very nice)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still have the "Test the latest stable release" job which does not alter the composer.json.

@Nyholm
Copy link
Member Author

Nyholm commented Nov 19, 2017

Ping @alcaeus

.travis.yml Outdated
- php: 7.1

# Test LTS versions
- php: 7.1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Food for thought: test the LTS releases against the lowest common version they and this package supports. I'd say that people on LTS releases are less likely to always run on the latest PHP version, so testing against a lower version might be more comparable to real-world usage.

.travis.yml Outdated
allow_failures:
# Latest beta is allowed to fail.
- php: 7.1
env: DEPENDENCIES="beta"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the latest beta should not be allowed to fail. Probably we really should allow it to fail, but I'm afraid people will not "notice" the failure. I'd rather push them to be a bit more proactive by noticing it :)

.travis.yml Outdated
- php: 7.1
env: DEPENDENCIES="symfony/lts:v3"

# Latest beta release
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest testing against dev rather than beta (especially if you allow them to fail):

  • if something breaks in an early Symfony 4.1 version, you may have 5 months to report it or adapt, instead of a few weeks/days
  • most of your other deps don't release beta at all, so you will not catch anything until it reaches other jobs too

@dbu dbu changed the title Test agains symfony versions Test against symfony versions Nov 27, 2017
Copy link
Contributor

@dbu dbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent, thanks for this cleanup!

lowest version build fails. i guess that is something about composer.json, maybe phpspec itself?

(and lets drop php 5.4 and 5.5 in the next minor version ;-) )

.travis.yml Outdated
@@ -27,18 +19,44 @@ branches:
matrix:
fast_finish: true
include:
# Minimum supported PHP and Symfony version
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minimum supported PHP is confusing here

.travis.yml Outdated

allow_failures:
# Latest beta is allowed to fail.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong comment

.travis.yml Outdated

allow_failures:
# Latest beta is allowed to fail.
- php: 7.1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to specify the PHP version here. It will avoid having to keep it in sync when changing the version used by DEPENDENCIES="dev"

.travis.yml Outdated
@@ -27,18 +19,44 @@ branches:
matrix:
fast_finish: true
include:
# Minimum supported PHP and Symfony version
- php: 7.1
env: DEPENDENCIES="minimum" COVERAGE=true TEST_COMMAND="composer test-ci"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we actually run the coverage on the min deps ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd do coverage on the latest stable

@@ -102,7 +102,7 @@ private function isJson($stream)

json_decode($stream->getContents());

return json_last_error() == JSON_ERROR_NONE;
return JSON_ERROR_NONE == json_last_error();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strict comparison ?

.travis.yml Outdated
before_install:
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
- if [ "$DEPENDENCIES" = "minimum" ]; then COMPOSER_FLAGS="--prefer-stable --prefer-lowest"; fi;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would instead just set $COMPOSER_FLAGS above

.travis.yml Outdated
before_install:
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
- if [ "$DEPENDENCIES" = "minimum" ]; then COMPOSER_FLAGS="--prefer-stable --prefer-lowest"; fi;
- if [ "$DEPENDENCIES" = "dev" ]; then composer config minimum-stability dev; fi;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rename the var to $STABILITY (or something like that) here

.travis.yml Outdated
before_install:
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
- if [ "$DEPENDENCIES" = "minimum" ]; then COMPOSER_FLAGS="--prefer-stable --prefer-lowest"; fi;
- if [ "$DEPENDENCIES" = "dev" ]; then composer config minimum-stability dev; fi;
- if [[ $DEPENDENCIES == *"/"* ]]; then composer require --no-update $DEPENDENCIES; fi;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and then just test for $DEPENDENCIES not being empty here

@Nyholm
Copy link
Member Author

Nyholm commented Nov 29, 2017

Thank you for the review. An Im sorry for keeping you review the actual travis file here and the "best practice" in the docs.

I've made the updates now

.travis.yml Outdated
@@ -27,18 +19,46 @@ branches:
matrix:
fast_finish: true
include:
- php: 7.1
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" DEPENDENCIES="doctrine/instanciator:^1.05"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's 1.0.5 ;)

.travis.yml Outdated
@@ -27,18 +19,46 @@ branches:
matrix:
fast_finish: true
include:
- php: 7.1
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" DEPENDENCIES="doctrine/instanciator:^1.0.5"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also instantiator. Apart from that, any reason why you're locking the version of it? If anything breaks with --prefer-lowest because an older version is installed, it needs to be fixed in that package and should probably be added here as a comment so the workaround can be removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is adding the dependency for this one case, so its changing composer.json and thus needs a version constraint.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that, the question is: why do you need it as an explicit dependency?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Slack:

@fbourigault [11:18 AM]
$ composer why doctrine/instantiator
phpspec/phpspec 2.4.0 requires doctrine/instantiator (^1.0.1)
phpspec/prophecy 1.4.0 requires doctrine/instantiator (^1.0.2) (edited)
But it’s for unmaintained versions of those packagesages

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Thank you for explaining 👍

.travis.yml Outdated
@@ -27,18 +19,47 @@ branches:
matrix:
fast_finish: true
include:
- php: 7.0
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" DEPENDENCIES="doctrine/instantiator:^1.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doctrine/instantiator:^1.1 require PHP 7.1.

@Nyholm
Copy link
Member Author

Nyholm commented Nov 30, 2017

Thank you for all the reviews!

@Nyholm Nyholm merged commit fcf5989 into master Nov 30, 2017
@Nyholm Nyholm deleted the Nyholm-patch-1 branch November 30, 2017 10:59
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Jan 15, 2018
…luz)

This PR was submitted for the master branch but it was merged into the 4.0 branch instead (closes #8701).

Discussion
----------

Added a good example of a travis file

After a lot of discussions with people at Symfony con I came up with a "perfect" travis file.

See php-http/client-common#90 (comment) for info.
Btw, should I make a table explaining what we really test? (Like on the client-common PR)

Commits
-------

93bdb86 Rewords
4bd8e65 Minor updates
bc9a43f use ./ before vendor
ae322b7 typo
1017897 Using better cache syntax
36ca90b Using PHPUNIT_FLAGS
18e4a18 Added back php-versions
05bf09d Moved coverage to PHP 7.2 with latest deps
bfdd064 Fixed minor things
3e2b876 Fixed typos and created more variables
a62bcb7 Added comment and install simple-phpunit deps
65f91df Use tilde or composer validate will never pass
179abb0 Updated according to feedback
a281604 Typo
2418834 Added a good example travis file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants